<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      @keyframes ColorChange {
        0% {
          outline: 1px solid lightgreen;
        }

        50% {
          outline: 1px solid green;
        }

        1000% {
          outline: 1px solid lightgreen;
        }
      }

      svg {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate3d(-50%, -50%, 0);
        outline: 1px solid red;
        animation: ColorChange 500ms ease infinite;
      }

      line,
      polyline,
      rect {
        stroke-linecap: round;
        stroke-linejoin: round;
      }
    </style>
  </head>

  <body>
    <svg width="600"
         height="600"
         xmlns="http://www.w3.org/2000/svg"
         xmlns:xlink="http://www.w3.org/1999/xlink"
         preserveAspectRatio="xMinYMin meet"
         stroke-linecap="round"
         stroke-linejoin="round"
         viewBox="0 0 600 600">
      <!-- 第十章 蒙版 -->
      <defs>
        <mask id="redmask"
              x="0"
              y="0"
              width="1"
              height="1"
              maskContentUnits="objectBoundingBox">
          <rect x="0"
                y="0"
                width="1"
                height="1"
                style="fill: #f00;" />
        </mask>
        <mask id="greenmask"
              x="0"
              y="0"
              width="1"
              height="1"
              maskContentUnits="objectBoundingBox">
          <rect x="0"
                y="0"
                width="1"
                height="1"
                style="fill: #0f0;" />
        </mask>
        <mask id="bluemask"
              x="0"
              y="0"
              width="1"
              height="1"
              maskContentUnits="objectBoundingBox">
          <rect x="0"
                y="0"
                width="1"
                height="1"
                style="fill: #00f;" />
        </mask>
        <mask id="whitemask"
              x="0"
              y="0"
              width="1"
              height="1"
              maskContentUnits="objectBoundingBox">
          <rect x="0"
                y="0"
                width="1"
                height="1"
                style="fill: #fff;" />
        </mask>

        <radialGradient id="fade">
          <stop offset="0%"
                style="stop-color: white; stop-opacity: 1.0;" />
          <stop offset="85%"
                style="stop-color: white; stop-opacity: 0.1;" />
          <stop offset="100%"
                style="stop-color: white; stop-opacity: 0.0;" />
        </radialGradient>
        <mask id="fademask"
              maskContentUnits="objectBoundingBox">
          <rect x="0"
                y="0"
                width="1"
                height="1"
                style="fill: url(#fade);" />
        </mask>
      </defs>
      <!-- 显示颜色以演示相对亮度 -->
      <rect x="10"
            y="10"
            width="50"
            height="50"
            style="fill: #f00;" />
      <rect x="70"
            y="10"
            width="50"
            height="50"
            style="fill: #0f0;" />
      <rect x="130"
            y="10"
            width="50"
            height="50"
            style="fill: #00f;" />
      <rect x="190"
            y="10"
            width="50"
            height="50"
            style="fill: #fff; stroke: black;" />
      <!-- 用于演示透明度的背景内容 -->
      <rect x="10"
            y="72"
            width="250"
            height="5"
            style="fill: yellow;" />
      <rect x="10"
            y="112"
            width="250"
            height="5"
            style="fill: yellow;" />
      <g style="mask: url(#redmask); font-size: 14pt; text-anchor: middle;">
        <circle cx="35"
                cy="115"
                r="25"
                style="fill: black;" />
        <text x="35"
              y="80">Red</text>
      </g>
      <g style="mask: url(#greenmask); font-size: 14pt; text-anchor: middle;">
        <circle cx="95"
                cy="115"
                r="25"
                style="fill: black;" />
        <text x="95"
              y="80">Green</text>
      </g>
      <g style="mask: url(#bluemask); font-size: 14pt; text-anchor: middle;">
        <circle cx="155"
                cy="115"
                r="25"
                style="fill: black;" />
        <text x="155"
              y="80">Blue</text>
      </g>
      <g style="mask: url(#whitemask); font-size: 14pt; text-anchor: middle;">
        <circle cx="215"
                cy="115"
                r="25"
                style="fill: black;" />
        <text x="215"
              y="80">White</text>
      </g>



      <image x="300"
             y="0"
             width="200"
             height="200"
             xlink:href="/source/sky.jpg"
             style="mask: url(#fademask);" />

    </svg>


    <script>
      const ele = document.querySelector("#xxx");
      let n = 0;
      function Renderer() {
        n++;
        if (n >= 360) n = 0;
        window.requestAnimationFrame(Renderer);
      }
      // Renderer();
    </script>
  </body>

</html>
